package com.example.flowerpcback.services;

import com.alibaba.fastjson.JSONObject;
import com.example.flowerpcback.dto.*;
import com.example.flowerpcback.exception.BusinessException;
import com.example.flowerpcback.exception.BusinessExceptionCode;
import com.example.flowerpcback.mapper.DictionaryMapper;
import com.example.flowerpcback.mapper.UserMapper;
import com.example.flowerpcback.mapper.UserMyMapper;
import com.example.flowerpcback.req.DictionaryReq;
import com.example.flowerpcback.req.UserReq;
import com.example.flowerpcback.resp.DictionaryResp;
import com.example.flowerpcback.resp.PageResp;
import com.example.flowerpcback.resp.UserResp;
import com.example.flowerpcback.utils.CopyUtil;
import com.example.flowerpcback.utils.SnowFlake;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class DictionaryService {
    private static final Logger LOG = LoggerFactory.getLogger(DictionaryService.class);

    @Resource
    private DictionaryMapper dictionaryMapper;

    public List<DictionaryResp> all(DictionaryReq req) {
        DictionaryExample dictionaryExample = new DictionaryExample();
        DictionaryExample.Criteria criteria = dictionaryExample.createCriteria();
        if(req.getType() != null) {
            criteria.andTypeEqualTo(req.getType());
        }

        List<Dictionary> res = dictionaryMapper.selectByExample(dictionaryExample);

        List<DictionaryResp> dictionaryResp = new CopyUtil().copyList(res,DictionaryResp.class);

        return dictionaryResp;
    }
}
